package com.twu.biblioteca.data;

import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by florian on 5/01/14.
 */
public class UserDAO {
    public static final User JOHN_DOE = new User("000-0001", "john", "John Doe", "john@doe.com", "000");
    private final Map<String,User> libraryNumberToUserMap = new HashMap<String, User>();

    public UserDAO() {
        Collection<User> users = Arrays.asList(
                JOHN_DOE,
                new User("000-0002","foo","Foo Bar", "foo@bar.com","111")
        );
        for (User user: users) {
            libraryNumberToUserMap.put(user.getLibraryNumber(), user);
        }
    }

    public User getUserByLibraryNumber(String libraryNumber) {
        return libraryNumberToUserMap.get(libraryNumber);
    }
}
